﻿using Jayden.Dll.Web.HtmlControls;
using Jayden.Dll.Web;

namespace Jayden.Site.Sterdent.Dll
{
	public class LangOl : Ol
	{
		public void ProcessRequest(HttpHandlerContext context)
		{
			
			foreach (Li li in GetControls<Li>())
			{
				foreach (A a in li.GetControls<A>())
				{
					string lang = a.GetServerAttribute("lang", null);
					if(lang != null)
					{
						Uri uri = context.Uri.Clone();
						a.HRefLang = lang;
						uri.Lang = lang;
						if (context.Lang == lang)
							li.Classes.Add("selected");
						a.HRef = context.Handler.UriManager.Virtualize(uri).ToAbsoluteString(true);
					}
				}
			}
		}

		public override void ProcessHtmlRequest(HttpHandlerContext context)
		{
			base.ProcessHtmlRequest(context);
			ProcessRequest(context);
		}
	}
}